package com.scenic.rd_android.design_model.mvp;

import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;

import com.scenic.rd_android.R;
import com.scenic.rd_android.design_model.mvp.presenter.AddEditTaskPresenter;
import com.scenic.rd_android.design_model.mvp.model.data.TaskRepository;
import com.scenic.rd_android.design_model.mvp.view.AddTaskFragment;

/**
 * https://github.com/googlesamples/android-architecture/tree/todo-mvp/
 */
public class MVPTestActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mvptest);

        AddTaskFragment fragment = (AddTaskFragment) getSupportFragmentManager().findFragmentById(R.id.id_frameLayout_content);

        if(fragment == null){
            fragment = AddTaskFragment.newInstance();
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.add(R.id.id_frameLayout_content,fragment ).commit();
        }




        new AddEditTaskPresenter(null,fragment,new TaskRepository());

    }
}
